<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>同积元组</title>
</head>
<body>
  <script>
    function fn(nums) {
      let obj = {}, sum = 0
      for (let i = 0; i < nums.length; i++) {
        for (let j = i + 1; j < nums.length; j++) {
          obj[nums[i] * nums[j]] ? obj[nums[i] * nums[j]] += 1 : obj[nums[i] * nums[j]] = 1
        }
      }
      for (let key in obj) {
        if (obj[key] > 1) {
          sum += 8 * obj[key] * (obj[key] - 1) / 2
        }
      }
      return sum
    }
    console.log(fn([2, 3, 4, 6]))
  </script>
</body>
</html>